/**
 ***********************************************************************************************************
 * 
 ***********************************************************************************************************
 * @file RBPixelBuffer.h
 ***********************************************************************************************************/

#ifndef __RBPIXELBUFFER_H__
#define __RBPIXELBUFFER_H__

#ifdef  HEADER_ONCE
#pragma HEADER_ONCE
#endif

#ifdef  HEADER_MSG
#pragma HEADER_MSG(RBPixelBuffer.h)
#endif

/***********************************************************************************************************
 * Includes
 ***********************************************************************************************************/
#include "RBMain/RBHardwareBuffer.h"
#include "RBMain/RBPixelFormat.h"
#include "RBMain/RBVector.h"

/***********************************************************************************************************
 * Forward declarations
 ***********************************************************************************************************/
class RBTexture;

/***********************************************************************************************************
 * Classes
 ***********************************************************************************************************/

class RBPixelBuffer : public RBHardwareBuffer
{
    RBDeclareRTTI(RBPixelBuffer, RBHardwareBuffer);
public:

    enum MSAA
    {
        MS_NONE = 0,
        MS_NONMASKABLE = 1 << 7, // Only Anti-aliasing
        MS_2_SAMPLES = 2,
        MS_3_SAMPLES = 3,
        MS_4_SAMPLES = 4,
        MS_5_SAMPLES = 5,
        MS_6_SAMPLES = 6,
        MS_7_SAMPLES = 7,
        MS_8_SAMPLES = 8,
        MS_9_SAMPLES = 9,
        MS_10_SAMPLES = 10,
        MS_11_SAMPLES = 11,
        MS_12_SAMPLES = 12,
        MS_13_SAMPLES = 13,
        MS_14_SAMPLES = 14,
        MS_15_SAMPLES = 15,
        MS_16_SAMPLES = 16
    };

                    RBPixelBuffer       (uint32 uiUsage, uint32 uiMemPoolMask, RBHardwareBufferManager* pCreator, 
                                         uint32 uiWidth, uint32 uiHeight, RBPixelFormat eFormat, uint32 uiMSAA,
                                         RBTexture* pContainer, void* pNative = NULL);

    virtual        ~RBPixelBuffer       ();

    RBPixelFormat   GetFormat           () const;
    uint32          GetWidth            () const;
    uint32          GetHeight           () const;
    uint32          GetMSAA             () const;
    RBTexture*      GetContainer        () const;

    virtual void    Resize              (uint32 uiWidth, uint32 uiHeight);

#pragma warning(push)
#pragma warning(disable: 4100)
    // Perform Blitting -> Do this when Box class is ready
    virtual void    Blit                (RBPixelBuffer* pDest, float2 srcStart = float2(0,0), float2 srcEnd = float2(1,1),
                                         float2 dstStart = float2(0,0), float2 dstEnd = float2(1,1)) const {};

    struct MappedBuffer
    {
        void* Data;
        uint32 Pitch;
    };

    virtual MappedBuffer Map            (MapType eMapType) { return MappedBuffer(); }
    virtual void         Unmap          () {};
#pragma warning(pop)

protected:

    RBPixelFormat   m_ePixelFormat;
    uint32          m_uiWidth;
    uint32          m_uiHeight;
    uint32          m_uiMSAA;
    RBTexture*      m_pContainer;
};

RBDeclareSmartPointer(RBPixelBuffer);

/***********************************************************************************************************
 * 
 ***********************************************************************************************************/
inline RBPixelFormat RBPixelBuffer::GetFormat() const
{
    return m_ePixelFormat;
}

/***********************************************************************************************************
 * 
 ***********************************************************************************************************/
inline uint32 RBPixelBuffer::GetWidth() const
{
    return m_uiWidth;
}

/***********************************************************************************************************
 * 
 ***********************************************************************************************************/
inline uint32 RBPixelBuffer::GetHeight() const
{
    return m_uiHeight;
}

/***********************************************************************************************************
 * 
 ***********************************************************************************************************/
inline uint32 RBPixelBuffer::GetMSAA() const
{
    return m_uiMSAA;
}

/***********************************************************************************************************
 * 
 ***********************************************************************************************************/
inline RBTexture* RBPixelBuffer::GetContainer() const
{
    return m_pContainer;
}

/***********************************************************************************************************/

#endif // __RBPIXELBUFFER_H__
